//
//  TKYSearchBarView.m
//  ProgressReportProject
//
//  Created by apple on 2018/4/24.
//  Copyright © 2018年 铁科院. All rights reserved.
//

#import "TKYSearchBarView.h"

@implementation TKYSearchBarView
- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        [self initUI];
    }
    return self;
}

- (void)initUI{
    
    UITextField *textField = [[UITextField alloc]initWithFrame:CGRectMake(10, 5, kScreenWidth- kWidthScale* 90, 30)];
    textField.placeholder = @"请选择搜索内容";
    textField.textAlignment = NSTextAlignmentCenter;
    textField.userInteractionEnabled = NO;
    textField.backgroundColor = kRGBColor(248, 248, 248, 1);
    [textField tky_cornerWithRadius:5 borderColor:nil borderWidth:0];
    self.textField = textField;
    [self addSubview:textField];
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(0, 0, kScreenWidth - kWidthScale *50, 30);
    [button addTarget:self action:@selector(clickAction:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:button];
    
    
    UIButton * searchBtn =  [UIButton buttonWithType:UIButtonTypeCustom];
    searchBtn.frame = CGRectMake(textField.kx_right +kWidthScale *10, 5, kWidthScale *50 , 30);
    [searchBtn setTitle:@"搜索" forState:UIControlStateNormal];
    [searchBtn setTitleColor:kRGBColor(106, 164, 234, 1) forState:UIControlStateNormal];
    [searchBtn addTarget:self action:@selector(searchClickAction:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:searchBtn];
}

- (void)clickAction:(UIButton *)button{
    if (self.seachbarBlock) {
        self.seachbarBlock(button);
    }
}

- (void)searchClickAction:(UIButton *)button{
    if (self.seachbarBtnBlock) {
        self.seachbarBtnBlock(button);
    }
}




@end
